#include "framework.h"



								
#define USER_CONFIG()											P00_Input_Mode();P12_PushPull_Mode()

#define EVENT_KEY_TEST_SHORT_PRESS									0x0001
#define EVENT_KEY_TEST_LONG_PRESS										0x0002



void key_scan()
{
	KEY_SCAN_SHORT_LONG(P00,KEY_SHORT_TIME,EVENT_KEY_TEST_SHORT_PRESS,KEY_LONG_TIME,EVENT_KEY_TEST_LONG_PRESS);
}


void main(void)
{
	USER_CONFIG();
	timer0_init(TIMER_LOAD_VALUE16(0.001,FOSC,12), key_scan);
	INTERRUPT_ENABLE();
	timer0_start();

	for(;;)
	{
		if(event_get(EVENT_KEY_TEST_SHORT_PRESS))
		{
			event_cancel(EVENT_KEY_TEST_SHORT_PRESS);
			P12 = 0;
		}
		else if(event_get(EVENT_KEY_TEST_LONG_PRESS))
		{
			event_cancel(EVENT_KEY_TEST_LONG_PRESS);
			P12 = 1;
		}
	}
}


